package com.his.struts.form;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;

/**
 * 用户form
 * @author liuyan
 *
 */
public class UserForm extends ActionForm {

	private Integer uid;
	
	private String sex;

	private Integer age;

	private String uemail;
	private String upicture;
	private FormFile pic;

	private String urole;

	private String ubirth;

	private String upass;

	private String uposs;

	private String uaddress;

	private String uphone;

	private String urealname;

	private String uname;

	/** 
	 * Method validate 表单验证
	 * @param mapping
	 * @param request
	 * @return ActionErrors
	 */
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		
		 
		if(pic != null){
			// 取出头像名称
			String fileName =pic.getFileName();
			
			  //图片类型
			if(fileName.endsWith(".jpg") || fileName.endsWith(".bmp") || fileName.endsWith(".gif") || fileName.endsWith(".jpeg")){
			int n = fileName.lastIndexOf(".");
			// 得到文件后缀名
			String houzhui = fileName.substring(n);
			// 设置头像名
			upicture = uid+houzhui;
			} else {
				pic = null;
			}
		} else {
			pic = null;
		}
		
		
		return null;
	}

	/** 
	 * Method reset 表单重置
	 * @param mapping
	 * @param request
	 */
	public void reset(ActionMapping mapping, HttpServletRequest request) {
	}

	public Integer getUid() {
		return uid;
	}

	public void setUid(Integer uid) {
		this.uid = uid;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public String getUemail() {
		return uemail;
	}

	public void setUemail(String uemail) {
		this.uemail = uemail;
	}

	public String getUpicture() {
		return upicture;
	}

	public void setUpicture(String upicture) {
		this.upicture = upicture;
	}

	public FormFile getPic() {
		return pic;
	}

	public void setPic(FormFile pic) {
		this.pic = pic;
	}

	public String getUrole() {
		return urole;
	}

	public void setUrole(String urole) {
		this.urole = urole;
	}

	public String getUbirth() {
		return ubirth;
	}

	public void setUbirth(String ubirth) {
		this.ubirth = ubirth;
	}

	public String getUpass() {
		return upass;
	}

	public void setUpass(String upass) {
		this.upass = upass;
	}

	public String getUposs() {
		return uposs;
	}

	public void setUposs(String uposs) {
		this.uposs = uposs;
	}

	public String getUaddress() {
		return uaddress;
	}

	public void setUaddress(String uaddress) {
		this.uaddress = uaddress;
	}

	public String getUphone() {
		return uphone;
	}

	public void setUphone(String uphone) {
		this.uphone = uphone;
	}

	public String getUrealname() {
		return urealname;
	}

	public void setUrealname(String urealname) {
		this.urealname = urealname;
	}

	public String getUname() {
		return uname;
	}

	public void setUname(String uname) {
		this.uname = uname;
	}
}